# -*- coding: utf-8 -*-

#使用拓展类的子类
from   rest_framework.response import Response
from  books.serializer import BookSerialzier,HeroInfoSerialzier
from  books.models import BookInfo,HeroInfo
from  rest_framework.generics import  ListCreateAPIView,RetrieveUpdateDestroyAPIView

class Books(ListCreateAPIView):
    queryset = BookInfo.objects.all()  # 指定当前类视图使用的查询集数据
    serializer_class = BookSerialzier  # 指定当前类视图使用的序列化器



class Book():
    def get(self, request):
        book = BookInfo.objects.get(id=1)
        ser = BookSerialzier(book)

        return Response(ser.data)


class BookDRFView(RetrieveUpdateDestroyAPIView):
    """
        获取单一和更新和删除
    """

    queryset = BookInfo.objects.all()  # 指定当前类视图使用的查询集数据
    serializer_class = BookSerialzier  # 指定当前类视图使用的序列化器
